<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator=">">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item :to="{path:getPath}" v-if="getPath =='/roles'">角色列表</el-breadcrumb-item>
      <el-breadcrumb-item :to="{path:getPath}" v-else>权限列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片 -->
    <el-card>
      <el-table style="width: 100%" border :data="rightsList">
         <el-table-column prop="prop" label="#" width="80" type="index" align="center">
         </el-table-column>
         <el-table-column prop="authName" label="权限名称" width="width">
         </el-table-column>
         <el-table-column prop="path" label="路径" width="width">
         </el-table-column>
         <el-table-column prop="prop" label="权限等级" width="width">
           <template v-slot="{row}">
             <el-tag v-if="row.level == '0'">一级</el-tag>
             <el-tag type="success" v-else-if="row.level == '1'">二级</el-tag>
             <el-tag type="warning" v-else>三级</el-tag>
           </template>
         </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
    name:'rights',
    data(){
        return{
            // 储存权限列表数据
            rightsList:[]
        }
    },
    methods:{
        // 获取权限列表数据
      async getRightsList(){
         let {data:result} = await this.$API.get(`rights/list`)
         if(result.meta.status == 200){
            this.rightsList = result.data
         }
      }
    },
    mounted(){
      this.getRightsList()
    },
    computed:{
      // 给面包屑导航当前的路由
      getPath(){
        return this.$route.path 
      }
    },
}
</script>

<style>

</style>